# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import os

from imbox import Imbox
import datetime
import time
import pendulum as pd

# 设定邮件存放文件夹
file_folder = '2022年应聘邮件'
mail_host = 'imap.qq.com'
# 设定接收邮箱许可证密码
mail_pass = 'gdhprdriyijibjfi'
# 可修改接收邮箱email:
sender = 'foxhuty@qq.com'


def get_mail_attachments():
    with Imbox(mail_host, username=sender, password=mail_pass, ssl=True) as imbox:
        inbox_messages_after = imbox.messages(date__gt=datetime.date(2022, 1, 1))
        for uid, message in inbox_messages_after[:2]:
            try:
                date_sent=message.date
                # print(dir(message))
                # print(date_sent)
                new_date=pd.parse(date_sent)
                print(new_date)

                # print(datetime.datetime(date_sent))
                # for i in date_sent.index:
                #     print(i)
                # print(datetime.timezone(date_sent))

                mail_date = message.parsed_date.time()
                # print(mail_date)
                # print(type(mail_date))
                # if message.attachments:
                #     for attachment in message.attachments:
                #         with open(f'D://爬虫数据//{attachment["filename"]}', mode='wb') as f:
                #             f.write(attachment['content'].getvalue())
                #             f.close()
                #             imbox.mark_seen(uid)
                #             print(f'{message.date}:---{attachment["filename"]}---下载完成。。。')
            except:
                pass


def now_to_date(time_stamp):

    format_string = "%Y-%m-%d %H:%M:%S"
    # time_stamp = int(time.time())
    time_array = time.localtime(time_stamp)
    str_date = time.strftime(format_string, time_array)
    return str_date


if __name__ == '__main__':
    # get_mail_attachments()

    # date_str = 'Tue, 16 Mar 2021 10:01:44 +0800'
    # email_date = date_str.split(",")[-1][1:-6]
    # new_date = int(time.mktime(time.strptime(email_date, "%d %b %Y %H:%M:%S")))
    # now=pd.now()
    # print(now.to_date_string())
    # set_time=pd.parse('2019-11-20 00:00:00',tz=now.tz)
    # print(set_time)
    # set_time1=pd.parse('2020-11-01 11:20:06',tz=now.tz)
    # print(set_time>set_time1)
    # print(os.scandir(path='D:\\'))
    # for i in os.scandir(path='D:\\'):
    #     print(i)
    for i in range(1,10):
        for j in range(1,i+1):
            print(f"{j}X{i}={i*j}",end='\t')
        print()









